<template>
  <div class="home-container">
    <!-- 顶部区块（包含导航栏和轮播图） -->
    <div class="header-section">
      <div class="header">
        <div class="logo">小牛看房</div>
        <div class="search-bar">
          <el-input
            v-model="searchQuery"
            placeholder="搜索好房"
            @focus="handleSearchFocus"
            @keyup.enter="handleSearch"
          >
            <template #prefix>
              <el-icon><Search /></el-icon>
            </template>
          </el-input>
        </div>
        <div class="header-icons">
          <span class="icon" @click="ToEcharts">价格数据</span>
          <span class="icon" @click="navigateToMap">地图</span>
        </div>
      </div>

      <div class="carousel-wrapper">
        <div class="carousel">
          <transition-group name="fade">
            <div v-for="(slide, index) in slides" 
                 :key="slide.id" 
                 v-show="currentIndex === index" 
                 class="carousel-item"
            >
              <div class="banner">
                <div class="banner-image" :style="{ backgroundImage: `url(${slide.image})` }"></div>
                <div class="banner-content">
                  <h1>{{ slide.title }}</h1>
                  <p>{{ slide.subtitle }}</p>
                </div>
              </div>
            </div>
          </transition-group>
          <div class="carousel-indicators">
            <span 
              v-for="(_, index) in slides" 
              :key="index"
              :class="['indicator', { active: currentIndex === index }]"
              @click="setSlide(index)"
            ></span>
          </div>
        </div>
      </div>
    </div>

    <!-- 功能区域统一容器 -->
    <div class="content-section functions-container">
      <!-- 房屋类型导航 -->
      <div class="functions-grid house-types-grid">
        <div
          v-for="item in type"
          :key="item.id"
          class="type-item"
          @click="handleCategoryClick(item.id)"
        >
          <div class="icon-container">
            <span class="icon">🏠</span>
          </div>
          <span class="type-name">{{ item.name }}</span>
        </div>
      </div>

      <!-- 功能导航 -->
      <div class="functions-grid feature-nav-grid">

          <div class="nav-item" @click="goToTransactionOne">
          <div class="nav-icon">⚖️</div>
          <span>查成交</span>
        </div>

          <div class="nav-item" @click="goToBusTwo">
          <div class="nav-icon">🚌</div>
          <span>公交找房</span>
        </div>

          <div class="nav-item" @click="goToHousingestateThree">
          <div class="nav-icon">🏘️</div>
          <span>找小区</span>
        </div>

           <div class="nav-item" @click="goToSchoolFour">
          <div class="nav-icon">🏫</div>
          <span>学校找房</span>
        </div>

          <div class="nav-item" @click="goToFlathuntingFive">
          <div class="nav-icon">🔍</div>
          <span>帮我找房</span>
        </div>
      </div>

      <!-- 房源操作区 -->
      <div class="functions-grid house-actions-grid">
        <div class="action-card">
          <div class="action-icon">➕</div>
          <div class="action-text">
            <h3>添加房产</h3>
            <p>房屋估价</p>
          </div>
        </div>
        <div class="action-card">
          <div class="action-icon">💰</div>
          <div class="action-text">
            <h3>我要出售</h3>
            <p>发布房源</p>
          </div>
        </div>
        <div class="action-card">
          <div class="action-icon">🔑</div>
          <div class="action-text">
            <h3>我要出租</h3>
            <p>出租房源</p>
          </div>
        </div>
      </div>
    </div>

    <!-- 热门推荐 -->
    <div class="content-section hot-houses">
      <div class="section-header">
        <h2>热门推荐</h2>
        <span class="more" @click="handleCategoryClick(3)">更多&gt;</span>
      </div>
      <div class="house-list">
        <div v-for="house in recommendedHouses.slice(0, displayLimit)"
             :key="house.id" 
             class="house-card"
             @click="goToDetail(house.id)">
          <img :src="getImageUrl(house.images)"
               :alt="house.title"
               @error="handleImageError" />
          <div class="house-info">
            <h3>{{ house.district }} · {{ house.title }}</h3>
            <div class="house-tags">
              <span class="tag">{{ house.house_type }}</span>
              <span class="tag">{{ house.decoration_type === 'medium' ? '精装' : '简装' }}</span>
            </div>
            <p class="price">{{ house.price }}{{ getPriceUnit(house.type) }}</p>
            <div v-if="house.recommendation_score !== undefined" class="score">
              推荐指数: {{ (house.recommendation_score * 100).toFixed(1) }}%
            </div>
          </div>
        </div>
      </div>
    </div>

    <!-- 推荐标签 -->
    <div class="content-section recommend-tags">
      <div class="tag" 
           :class="{ active: activeTag === '推荐' }" 
           @click="handleTagClick('推荐')">推荐</div>
      <div class="tag" 
           :class="{ active: activeTag === '二手房' }" 
           @click="handleTagClick('二手房')">二手房</div>
      <div class="tag" 
           :class="{ active: activeTag === '新房' }" 
           @click="handleTagClick('新房')">新房</div>
      <div class="tag" 
           :class="{ active: activeTag === '租房' }" 
           @click="handleTagClick('租房')">租房</div>
    </div>

    <!-- 房源列表 -->
    <div class="content-section house-listings" v-if="displayHouses.length > 0">
      <div class="recommended-list">
        <div v-for="house in displayHouses" 
             :key="house.id" 
             class="recommended-card" 
             @click="goToDetail(house.id)">
          <div class="house-image">
            <img :src="getImageUrl(house.images)"
                 :alt="house.title"
                 @error="handleImageError" />
            <span class="status-tag" v-if="house.status === 'available'">
              {{ [2, 3, 4].includes(house.type) ? '可售' : '可租' }}
            </span>
          </div>
          <div class="house-info">
            <h3 class="house-title">{{ house.title }}</h3>
            <div class="house-tags">
              <span class="tag">{{ house.house_type }}</span>
              <span class="tag">{{ house.decoration_type === 'medium' ? '精装' : '简装' }}</span>
              <span class="tag">{{ house.orientation === 'south' ? '朝南' : house.orientation }}</span>
            </div>
            <div class="house-details">
              <span class="area">{{ house.area }}m²</span>
              <span class="floor">{{ house.floor }}/{{ house.total_floor }}层</span>
            </div>
            <div class="location-info">
              <el-icon><Location /></el-icon>
              <span>{{ house.district }} - {{ house.address }}</span>
            </div>
            <div class="price-info">
              <div class="price-section">
                <span class="price">{{ house.price }}</span>
                <span class="unit">{{ getPriceUnit(house.type) }}</span>
              </div>
              <div class="deposit-info" v-if="house.type === 1">押金：{{ house.deposit }}元</div>
            </div>
          </div>
        </div>
      </div>
    </div>

    <!-- 底部导航栏 -->
    <div class="bottom-nav">
      <div class="nav-item" :class="{ active: route.path === '/' }" @click="navigateTo('/')" >
        <el-icon><HomeFilled /></el-icon>
        <span>看点</span>
      </div>
      <div class="nav-item" :class="{ active: route.path === '/my-home' }" @click="navigateTo('/my-home')" >
        <el-icon><Lightning /></el-icon>
        <span>我家</span>
      </div>
      <div class="nav-item" :class="{ active: route.path === '/messages' }" @click="navigateTo('/messages')" >
        <el-icon><ChatDotRound /></el-icon>
        <span>消息</span>
      </div>
      <div class="nav-item" :class="{ active: route.path === '/profile' }" @click="navigateTo('/profile')" >
        <el-icon><User /></el-icon>
        <span>我的</span>
      </div>
    </div>
  </div>
</template>


<script setup>
import { ref, onMounted, onBeforeUnmount, computed } from 'vue'
import axios from "axios";
import { useRouter, useRoute } from "vue-router";
import { HomeFilled, Lightning, ChatDotRound, User, Location, Search } from '@element-plus/icons-vue'
import { ElMessage } from 'element-plus'

const router = useRouter();
const route = useRoute();
const type = ref([]);
const currentIndex = ref(0);
const timer = ref(null);
const recommendedHouses = ref([]); // 推荐房源列表
const hotNewHouses = ref([]); // 热门新房列表
const displayHouses = ref([]); // 当前显示的房源列表
const activeTag = ref('推荐'); // 当前激活的标签
const isLoading = ref(false); // 加载状态
const userId = ref(localStorage.getItem('userId')); // 从localStorage获取用户ID
const searchQuery = ref('')
const ToEcharts = () => {
  router.push('/ec');
};
// 默认图片URL
const defaultImage = 'https://img.freepik.com/free-vector/house-isolated-field_1308-26795.jpg';

// 处理图片加载错误
const handleImageError = (event) => {
  event.target.src = defaultImage;
};

// 获取图片URL
const getImageUrl = (images) => {
  if (!images || !images.length || !images[0]) {
    return defaultImage;
  }
  return images[0];
};

// 计算属性：显示数量限制
const displayLimit = computed(() => {
  return userId.value ? recommendedHouses.value.length : 3;
});

// 轮播图数据
const slides = ref([
  {
    id: 1,
    title: '常州新政补贴新房一览表',
    subtitle: '小牛看房专属额外最高1%补贴 领跑全城',
    image: 'https://images.pexels.com/photos/323780/pexels-photo-323780.jpeg'
  },
  {
    id: 2,
    title: '品质好房 精选推荐',
    subtitle: '为您严选优质房源',
    image: 'https://images.pexels.com/photos/1396122/pexels-photo-1396122.jpeg'
  },
  {
    id: 3,
    title: '置业优选 专享特惠',
    subtitle: '多重优惠 品质保障',
    image: 'https://images.pexels.com/photos/1643384/pexels-photo-1643384.jpeg'
  }
]);

// 获取房源列表数据
const getHouseList = async (type) => {
  try {
    // 检查登录状态
    const storedUserId = localStorage.getItem('userId')
    const pageSize = storedUserId ? 10 : 3 // 未登录时只获取3条数据

    const response = await axios.get('http://127.0.0.1:8000/users/house/list/', {
      params: {
        type: type,
        page: 1,
        page_size: pageSize
      }
    })
    if (response.data && Array.isArray(response.data.results)) {
      // 未登录时添加默认推荐分数
      displayHouses.value = storedUserId ? response.data.results :
        response.data.results.map(house => ({
          ...house,
          recommendation_score: 1
        }))
    }
  } catch (error) {
    console.error('房源列表获取失败:', error)
    ElMessage.error('获取房源列表失败')
  }
}

// 获取AI推荐房源
const getAIRecommendations = async () => {
  try {
    isLoading.value = true;
    const token = localStorage.getItem('token');
    if (!token) {
      console.log('未登录，获取默认房源列表');
      getHousesByType(1);
      return;
    }

    const response = await axios.get('/users/house/recommend/', {
      params: {
        limit: 10
      }
    });

    console.log('推荐接口响应:', response);

    if (response.data.code === 200) {
      recommendedHouses.value = response.data.data;
      displayHouses.value = recommendedHouses.value;
      if (recommendedHouses.value.length === 0) {
        console.log('暂无推荐房源，显示默认列表');
        getHousesByType(1);
      }
    } else {
      console.error('获取推荐失败:', response.data.msg);
      getHousesByType(1); // 获取默认房源列表
    }
  } catch (error) {
    console.error('获取AI推荐失败:', error);
    getHousesByType(1); // 获取默认房源列表
  } finally {
    isLoading.value = false;
  }
};

// 记录用户浏览行为
const recordHouseView = async (houseId) => {
  try {
    const token = localStorage.getItem('token');
    if (!token) {
      return; // 未登录用户不记录浏览行为
    }

    await axios.post('/users/house/recommend/', {
      house_id: houseId
    });
  } catch (error) {
    console.error('记录浏览行为失败:', error);
  }
};

// 根据类型获取房源列表
const getHousesByType = (houseType) => {
  axios.get(`http://127.0.0.1:8000/users/house/list/?type=${houseType}`)
    .then(res => {
      displayHouses.value = res.data.results;
    })
    .catch(error => console.error('房源列表获取失败:', error));
};
// 获取推荐房源
const fetchRecommendedHouses = async () => {
  try {
    const response = await axios.get('http://127.0.0.1:8000/users/house/list/', {
      params: {
        page: 1,
        page_size: 3
      }
    })
    if (response.data && Array.isArray(response.data.results)) {
      recommendedHouses.value = response.data.results
    }
  } catch (error) {
    console.error('获取房源失败:', error)
    ElMessage.error('获取房源失败')
    recommendedHouses.value = []
  }
}

// 处理标签点击
const handleTagClick = async (tag) => {
  activeTag.value = tag;
  isLoading.value = true;

  try {
    switch(tag) {
      case '推荐':
        await getAIRecommendations();
        displayHouses.value = recommendedHouses.value;
        break;
      case '租房':
        await getHousesByType(1);
        break;
      case '新房':
        await getHousesByType(3);
        break;
      case '二手房':
        await getHousesByType(4);
        break;
    }
  } catch (error) {
    console.error('获取房源列表失败:', error);
  } finally {
    isLoading.value = false;
  }
}

// 自动轮播
const startAutoPlay = () => {
  timer.value = setInterval(() => {
    nextSlide();
  }, 3000);
};

const stopAutoPlay = () => {
  if (timer.value) {
    clearInterval(timer.value);
    timer.value = null;
  }
};

const nextSlide = () => {
  currentIndex.value = (currentIndex.value + 1) % slides.value.length;
};

const setSlide = (index) => {
  currentIndex.value = index;
};

// 获取房屋类型数据
const gettype = () => {
  axios.get('http://127.0.0.1:8000/users/house/type/')
    .then(res => {
      type.value = res.data;
    })
    .catch(error => console.error('数据获取失败:', error));
};

// 分类点击处理函数
const handleCategoryClick = (categoryId) => {
  router.push({
    path: '/about',
    query: {
      type: categoryId
    }
  });
};

// 导航方法
const navigateTo = (path) => {
  router.push(path);
};

// 获取价格单位
const getPriceUnit = (type) => {
  switch (Number(type)) {
    case 1:
      return '元/月'
    case 2:
    case 3:
    case 4:
      return '元/m²'
    default:
      return '元/月'
  }
};

// 修改跳转到详情页面的方法，添加交互记录
const goToDetail = (id) => {
  router.push({
    path: '/house-detail',
    query: { id: id }
  })
};

// 添加地图导航方法
const navigateToMap = () => {
  router.push('/map')
};

const handleSearch = () => {
  if (searchQuery.value.trim()) {
    router.push({
      path: '/house-search',
      query: { 
        text: searchQuery.value
      }
    })
  }
}

onMounted(async () => {
  try {
    await gettype() // 获取房屋类型
    await fetchRecommendedHouses() // 获取推荐房源
    startAutoPlay() // 开始轮播
  } catch (error) {
    console.error('初始化失败:', error)
    ElMessage.error('页面加载失败')
  }
});

onMounted(() => {
  gettype();
  getHouseList();
  getAIRecommendations(); // 默认加载AI推荐房源
  startAutoPlay();
});

onBeforeUnmount(() => {
  stopAutoPlay();
});




const goToTransactionOne = () => {
  window.location.href = 'http://localhost:5173/transactionOne';
};

const goToBusTwo = () => {
  window.location.href = 'http://localhost:5173/busTwo';
};

const goToSchoolFour = () => {
  window.location.href = 'http://localhost:5173/schoolFour';
};

const goToFlathuntingFive = () => {
  window.location.href = 'http://localhost:5173/flathuntingFive';
};
const goToHousingestateThree = () => {
  window.location.href = 'http://localhost:5173/housingestateThree';
};

// 处理搜索框获得焦点
const handleSearchFocus = () => {
  router.push('/searchView')
}



</script>

<style scoped>
.home-container {
  min-height: 100vh;
  background: #F5F5DC;  /* 更改为浅米色背景 */
  padding-bottom: 80px;
}

.header-section {
  background: linear-gradient(135deg, #9575CD, #7E57C2);  /* 降低紫色亮度 */
  padding: 16px 16px 0;
  margin-bottom: 20px;
  border-radius: 0 0 20px 20px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 15px;
  padding: 0 4px;
}

.logo {
  color: #000000;
  font-size: 22px;
  font-weight: bold;
  display: flex;
  align-items: center;
  gap: 4px;
}

.search-bar {
  flex: 1;
  margin: 0 15px;
  position: relative;
}

.search-bar input {
  width: 100%;
  padding: 10px 20px;
  border-radius: 25px;
  border: none;
  background: rgba(255, 255, 255, 0.95);
  font-size: 14px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.header-icons {
  display: flex;
  gap: 20px;
  color: white;
  font-size: 14px;
}

.header-icons .icon {
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 15px;
  transition: all 0.3s ease;
}

.header-icons .icon:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.carousel-wrapper {
  position: relative;
  height: 160px;
  border-radius: 12px;
  overflow: hidden;
  margin: 0 4px;
}

.carousel {
  position: relative;
  height: 100%;
  width: 100%;
}

.carousel-item {
  position: absolute;
  height: 100%;
  width: 100%;
  left: 0;
  top: 0;
}

.banner {
  position: relative;
  height: 100%;
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.banner-image {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.banner-content {
  position: relative;
  z-index: 1;
  padding: 20px;
  background: linear-gradient(to bottom, 
    rgba(107, 47, 212, 0.3),
    rgba(65, 105, 225, 0.7)
  );
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.banner h1 {
  font-size: 20px;
  margin-bottom: 8px;
  font-weight: bold;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
  color: white;
}

.banner p {
  font-size: 14px;
  opacity: 0.95;
  line-height: 1.4;
  text-shadow: 0 1px 1px rgba(0,0,0,0.3);
  color: white;
  text-align: center;
}

.carousel-indicators {
  position: absolute;
  bottom: 15px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 8px;
  z-index: 2;
}

.indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  transition: all 0.3s ease;
}

.indicator.active {
  background: white;
  transform: scale(1.2);
}

.content-section {
  background: #FFFFFF;
  border-radius: 16px;
  margin: 0 16px 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  position: relative;
  overflow: hidden;
  border: 1px solid #E0E0E0;  /* 添加浅灰色边框 */
}

.content-section::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(to right, #4CAF50, #45A049);  /* 更改为绿色渐变 */
  opacity: 0.2;
}

.functions-container {
  background: #FFFFFF;
  border-radius: 16px;
  margin: 0 16px 16px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.functions-grid {
  margin-bottom: 20px;
  padding: 15px 10px;
  border-bottom: 1px solid #E0E0E0;
}

.functions-grid:last-child {
  margin-bottom: 0;
  border-bottom: none;
}

.house-types-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 15px;
}

.feature-nav-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
}

.house-actions-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 15px;
}

.type-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 12px 8px;
  border-radius: 12px;
  background: #F5F5F5;
}

.type-item:hover {
  transform: translateY(-2px);
  background: #E8F5E9;
}

.icon-container {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, #4CAF50, #45A049);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: white;
  box-shadow: 0 2px 8px rgba(76, 175, 80, 0.2);
}

.type-name {
  font-size: 14px;
  color: #000000;
  font-weight: 600;
  text-align: center;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid transparent;
}

.nav-item:hover {
  transform: translateY(-2px);
  background: #FFF8E1;
  border-color: #FFE0B2;
}

.nav-icon {
  font-size: 24px;
  color: #FF9800;  /* 橙色图标 */
  margin-bottom: 4px;
}

.nav-item span {
  font-size: 13px;
  color: #000000;
  font-weight: 600;
}

.action-card {
  background: linear-gradient(to bottom, #FFFFFF, #F5F5F5);
  padding: 15px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
  border: 1px solid #E0E0E0;
}

.action-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.15);
  border-color: #C8E6C9;
  background: linear-gradient(to bottom, #FFFFFF, #E8F5E9);
}

.action-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #FF9800, #FB8C00);  /* 橙色渐变 */
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: white;
}

.action-text {
  flex: 1;
}

.action-text h3 {
  font-size: 15px;
  color: #000000;
  margin-bottom: 4px;
  font-weight: 600;
}

.action-text p {
  font-size: 12px;
  color: #000000;
  font-weight: 500;
}

.hot-houses {
  padding: 15px;
}

.hot-houses .section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  padding: 0 5px;
}

.section-header h2 {
  font-size: 17px;
  color: #000000;
  font-weight: bold;
}

.more {
  color: #000000;
  font-size: 13px;
  cursor: pointer;
  font-weight: 500;
}

.house-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.house-card {
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  transition: transform 0.2s ease;
  background: white;
}

.house-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.house-card img {
  width: 100%;
  height: 110px;
  object-fit: cover;
  background: #f5f5f5;
}

.house-info {
  padding: 10px;
}

.house-info h3 {
  font-size: 13px;
  color: #000000;
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
}

.price {
  color: #FF4D4F;
  font-size: 15px;
  font-weight: bold;
}

.recommend-tags {
  display: flex;
  gap: 12px;
  padding: 15px;
  background: #FFFFFF;
  border-radius: 16px;
  margin: 0 16px 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.tag {
  color: #000000;
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 500;
  background: #F5F5F5;
  transition: all 0.3s ease;
  border: 1px solid transparent;
}

.tag:hover {
  background: #E8F5E9;
  transform: translateY(-1px);
  border-color: #4CAF50;
}

.tag.active {
  background: #4CAF50;
  color: #FFFFFF;
  font-weight: 600;
  border-color: #4CAF50;
  box-shadow: 0 2px 6px rgba(76, 175, 80, 0.2);
}

.tag.active:hover {
  background: #43A047;
  transform: translateY(-1px);
}

/* 轮播图动画 */
.fade-enter-active,
.fade-leave-active {
  transition: opacity 0.5s ease;
}

.fade-enter-from,
.fade-leave-to {
  opacity: 0;
}

.recommended-houses {
  padding: 15px;
}

.recommended-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.recommended-card {
  background: #FFFFFF;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  display: flex;
  padding: 16px;
  gap: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.recommended-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.recommended-card .house-image {
  position: relative;
  width: 160px;
  height: 120px;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
}

.recommended-card .house-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.recommended-card .status-tag {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(76, 175, 80, 0.9);
  color: white;
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 1px;
}

.recommended-card .house-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.recommended-card .house-title {
  font-size: 18px;
  font-weight: 600;
  color: #000000;
  margin: 0;
  line-height: 1.4;
}

.recommended-card .house-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.recommended-card .tag {
  background: #F5F5F5;
  color: #000000;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}

.recommended-card .house-details {
  display: flex;
  gap: 16px;
  color: #000000;
  font-size: 14px;
  font-weight: 500;
}

.recommended-card .location-info {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #666666;
  font-size: 14px;
}

.recommended-card .location-info .el-icon {
  font-size: 16px;
  color: #4CAF50;
}

.recommended-card .price-info {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.recommended-card .price-section {
  display: flex;
  align-items: baseline;
  background: #FFF5F5;
  padding: 4px 8px;
  border-radius: 4px;
}

.recommended-card .price {
  color: #FF5252;
  font-size: 24px;
  font-weight: 600;
}

.recommended-card .unit {
  color: #FF5252;
  font-size: 14px;
  margin-left: 4px;
  font-weight: 500;
}

.recommended-card .deposit-info {
  color: #666666;
  font-size: 14px;
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: #311B92;
  display: flex;
  justify-content: space-around;
  align-items: center;
  box-shadow: 0 -1px 8px rgba(0, 0, 0, 0.1);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 1000;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 12px;
  padding: 8px 0;
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-item .el-icon {
  font-size: 24px;
}

.nav-item.active {
  color: #FFFFFF;
}

.house-card .house-tags {
  display: flex;
  gap: 6px;
  margin: 4px 0;
}

.house-card .tag {
  background: #F5F5F5;
  color: #666666;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
}

.house-card .score {
  color: #4CAF50;
  font-size: 12px;
  margin-top: 4px;
  font-weight: 500;
}

.house-card:hover .score {
  color: #2E7D32;
}
</style>